.\"
.\" This file and its contents are supplied under the terms of the
.\" Common Development and Distribution License ("CDDL"), version 1.0.
.\" You may only use this file in accordance with the terms of version
.\" 1.0 of the CDDL.
.\"
.\" A full copy of the text of the CDDL should have accompanied this
.\" source.  A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
.\" Copyright (c) 2014, Joyent, Inc.
.\"
.Dd "Nov 26, 2017"
.Dt GETPROGNAME 3C
.Os
.Sh NAME
.Nm getprogname ,
.Nm setprogname
.Nd get or set the program name
.Sh SYNOPSIS
.In stdlib.h
.Ft const char *
.Fo getprogname
.Fa void
.Fc
.Ft void
.Fo setprogname
.Fa "const char *progname"
.Fc
.Sh DESCRIPTION
The
.Fn getprogname
function is used to obtain the program name.
The program name is set at program start-up, before
.Fn main
is called.
Note, other operating systems, do not guarantee that a program name has been set
at start up time and therefore may return a null pointer if
.Fn setprogname
has not been called.
.Lp
The
.Fn setprogname
function is used to change the program name to another value.
The argument
.Fa progname
must contain a null terminated character string, whose last component
which will become the new program name.
.Sh RETURN VALUES
The
.Fn getprogname
function always returns the current program name.
The program name is always set, it will not return a null pointer.
.Sh INTERFACE STABILITY
.Sy Committed
.Sh MT-LEVEL
.Fn getprogname
is
.Sy MT-Safe .
.Lp
.Fn setprogname
is
.Sy Unsafe .
.Sh SEE ALSO
.Xr err 3c ,
.Xr attributes 7
.Sh NOTES
The use of
.Fn setprogname
does not modify the program name as reported by utilities like
.Xr ps 1
or
.Xr pargs 1 ;
however, it does ensure a consistent program name for the
.Xr err 3C
family of functions.
